//////////Change the directory before running the code
//// Load events file
cd "D:\data&code"
use pseudo_dataset/events, clear

///// Count events per each category
sort proxy_year

mark voted if contest == 1
by proxy_year : egen num_voted = sum(voted)

mark settled if contest == 2
by proxy_year : egen num_settled = sum(settled)

mark withdrawn if contest == 3
by proxy_year : egen num_withdrawn = sum(withdrawn)

by proxy_year : keep if _n == 1
keep proxy_year num_voted num_settled num_withdrawn

rename num_voted     voted
rename num_settled   settled
rename num_withdrawn withdrawn

gen all = voted + settled + withdrawn



